/* 
 * File:   BackendMiddlewareHandler.h
 * Author: toantm
 *
 * Created on September 20, 2012, 2:52 PM
 */

#ifndef BACKENDMIDDLEWAREHANDLER_H
#define	BACKENDMIDDLEWAREHANDLER_H

#include "BackendMiddleware.h"
#include <iostream>
#include <Poco/Logger.h>
#include <Poco/Mutex.h>

using namespace ::BackendMiddleware;
using Poco::Logger;
using Poco::FastMutex;

class BackendMiddlewareHandler : public BackendMiddlewareIf {
public:
    typedef Poco::FastMutex Mutex;
public:
    BackendMiddlewareHandler();
    BackendMiddlewareHandler(const BackendMiddlewareHandler& orig);
    virtual ~BackendMiddlewareHandler();
public:
    void getAllTag(std::vector<Tag> & _return);
    bool insertTag(const std::string& tagName);
    bool deleteTag(const std::string& tagKey);
    bool updateTag(const std::string& tagKey, const std::string& tagName);
    void getAllItem(std::vector<Item> & _return);
    void getRandomItems(std::vector<Item> & _return, const int32_t itemNumber);
    bool postOnWall(const std::string& userID);
    void getItemsPage(std::vector<Item> & _return, const int32_t pageNumber, const int32_t itemNumber);
    bool insertItem(const std::string& itemName, const std::string& tagKey);
    bool deleteItem(const std::string& itemKey);
    bool updateItem(const std::string& itemKey, const std::string& itemName, const std::string& tagKey);
    void searchItemTag(std::vector<Item> & _return, const std::string& tagKey);
    void searchItemKeyword(std::vector<Item> & _return, const std::string& keyWord);
    void backLastSelect(Item& _return, const std::string& userName);
    void getBestTags(std::vector<Tag> & _return);
    void getBestItems(std::vector<Item> & _return);
    bool saveFavoriteItem(const std::string& itemKey, const std::string& userName);
    bool blockUser(const std::string& userID);
    bool unBlockUser(const std::string& userID);
private:
    Logger* _logger;
    Mutex _mutex;
};

#endif	/* BACKENDMIDDLEWAREHANDLER_H */

